import { UserProfilesAPI } from "@/request/api";

export default {
    namespaced: true,
    state:{
        userInfo: {
            nickName: '--',
            coin: 0,
            headImg: require('../../assets/img/userImg.f8bbec5e.png'),
        },
        cartTotal: 0
    },
    mutations: {
        changeUserInfo(state, payload) {
            state.userInfo = payload.userInfo;
            state.cartTotal = payload.cartTotal;
        },
        // 初始化仓库属性
        initUserInfo(state) {
            state.userInfo = {
                nickName: '--',
                coin: 0,
                headImg: require('../../assets/img/userImg.f8bbec5e.png')
            }
            state.cartTotal = 8;
        }
    },
    actions: {
        async asyncchangeUserInfo({
            commit
        }) {
            let user = await UserProfilesAPI();
            // console.log("用户信息",user);
            commit("changeUserInfo",user.data)
        }
    }
}